package com.zjc.springboot.test;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.zjc.springboot.delayqueue.event.Msg;
import com.zjc.springboot.delayqueue.event.MsgEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

@Component
public class MsgEventLisenter implements ApplicationListener<MsgEvent> {

    private static Gson gson = new GsonBuilder().create();

    @Override
    public void onApplicationEvent(MsgEvent event) {

        Msg msg = event.getMsg();

        System.out.println(gson.toJson(msg));

        //TODO: 对监听到的事件进行处理
    }
}
